Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@wooorm/starry-night
Advanced tools
Close up of The Starry Night by Vincent van Gogh (1889)
with examples of starry-night
over it
Syntax highlighting, like what GitHub uses to highlight code, but free and open source and JavaScript!
PrettyLights
?This package is an open source version of GitHub’s closed-source PrettyLights
project (more on that later).
It supports 520+ grammars and its extremely high quality.
It uses TextMate grammars which are also used in popular editors (SublimeText,
Atom, VS Code, &c).
They’re heavy but high quality.
starry-night
is a high quality highlighter
(when your readers or authors are programmers, you want this!)
that can support tons of grammars
(from new things like Astro to much more!)
which approaches how GitHub renders code.
It has a WASM dependency, and rather big grammars, which means that
starry-night
might be too heavy particularly in browsers, in which case
lowlight
or refractor
might be more suitable.
This project is similar to the excellent shiki
, and it uses the same
underlying dependencies, but starry-night
is meant to match GitHub in that it
produces classes and works with the CSS it ships, making it easier to add dark
mode and other themes with CSS compared to inline styles.
Finally, this package produces objects (an AST), which makes it useful when you
want to perform syntax highlighting in a place where serialized HTML wouldn’t
work or wouldn’t work well.
For example, when you want to show code in a CLI by rendering to ANSI sequences,
when you’re using virtual DOM frameworks (such as React or Preact) so that
diffing can be performant, or when you’re working with hast
or
rehype
.
Bundled, minified, and gzipped, starry-night
and the WASM binary are 185 kB.
There are two lists of grammars you can use: common
(33 languages, good for
your own site) adds 160 kB and all
(520+ languages, useful if are making a
site like GitHub) is 1.35 MB.
You can also manually choose which grammars to include (or add to common
): a
language is typically between 3 and 5 kB.
As an example, adding Astro to starry-night
with the common
grammars costs
an additional 1.5 kB.
PrettyLights
?PrettyLights
is the syntax highlighter that GitHub uses to turn this:
```markdown
# Hello, world!
```
…into this:
<span class="pl-mh"><span class="pl-mh">#</span><span class="pl-mh"> </span>Hello, world!</span>
…which is what starry-night
does too (some small differences in markup, but
essentially the same)!
PrettyLights
is responsible for taking the flag markdown
, looking it up in
languages.yml
from github/linguist
to figure out that that
means markdown, taking a corresponding grammar (in this case
atom/language-gfm
), doing some GPL magic in C, and turning it
into spans with classes.
GitHub is using PrettyLights
since December 2014, when it
replaced Pygments
.
They wanted to open source it, but were unable due to licensing issues.
Recently (Feb 2019?), GitHub has slowly started to move towards
TreeLights
, which is based on TreeSitter, and also closed source.
If TreeLights
includes a language (currently: CSS, CodeQL, EJS, Elixir, Go,
HTML, JS, PHP, Python, Ruby, TS), that’ll be used, for everything else
PrettyLights
is used.
starry-night
does what PrettyLights
does, not what TreeLights
does.
I’m hopeful that that will be open sourced in the future and we can mimic both.
This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with npm:
npm install @wooorm/starry-night
In Deno with esm.sh
:
import {createStarryNight, common} from 'https://esm.sh/@wooorm/starry-night@1'
In browsers with esm.sh
:
<script type="module">
import {createStarryNight, common} from 'https://esm.sh/@wooorm/starry-night@1?bundle'
</script>
To get the CSS in browsers, do (see CSS for more info):
<!-- This supports light and dark mode automatically. -->
<link rel="stylesheet" href="https://esm.sh/@wooorm/starry-night@1/style/both.css">
import {createStarryNight, common} from '@wooorm/starry-night'
const starryNight = await createStarryNight(common)
const scope = starryNight.flagToScope('markdown')
const tree = starryNight.highlight('# hi', scope)
console.log(tree)
Yields:
{
type: 'root',
children: [
{
type: 'element',
tagName: 'span',
properties: {className: ['pl-mh']},
children: [{type: 'text', value: '# hi'}]
}
]
}
This package exports the identifiers createStarryNight
, common
, and all
.
There is no default export.
createStarryNight(grammars[, options])
Create a StarryNight
that can highlight things based on the given grammars
.
This is async to facilitate async loading and registering, which is currently
only used for WASM.
grammars
(Array<Grammar>
)
— grammars to supportoptions
(Options
)
— configurationPromise that resolves to an instance which highlights based on the bound
grammars (Promise<StarryNight>
).
Options
Configuration (optional).
options.getOnigurumaUrlFetch
Get a URL to the oniguruma WASM, typically used in browsers (GetOnigurumaUrl
,
optional).
options.getOnigurumaUrlFs
Get a URL to the oniguruma WASM, typically used in Node.js (GetOnigurumaUrl
,
optional).
GetOnigurumaUrl
Function to get a URL to the oniguruma WASM.
👉 Note: this must currently result in a version 1 URL of
onig.wasm
fromvscode-oniguruma
.
⚠️ Danger: when you use this functionality, your project might break at any time (when reinstalling dependencies), except when you make sure that the WASM binary you load manually is what our internally used
vscode-oniguruma
dependency expects. To solve this, you could for example use an npm script calleddependencies
(which runs everytimenode_modules
is changed) which copiesvscode-oniguruma/release/onig.wasm
to the place you want to host it.
URL object to a WASM binary (URL
or Promise<URL>
).
import {createStarryNight, common} from '@wooorm/starry-night'
const starryNight = await createStarryNight(common, {
getOnigurumaUrlFetch() {
return new URL('/onig.wasm', window.location.href);
}
})
starryNight.highlight(value, scope)
Highlight value
(code) as scope
(a TextMate scope).
value
(string
)
— code to highlightscope
(string
)
— registered grammar scope to highlight as (such as 'source.gfm'
)Node representing highlighted code (Root
).
import {createStarryNight} from '@wooorm/starry-night'
import sourceCss from '@wooorm/starry-night/lang/source.css.js'
const starryNight = await createStarryNight([sourceCss])
console.log(starryNight.highlight('em { color: red }', 'source.css'))
Yields:
{
type: 'root',
children: [
{type: 'element', tagName: 'span', properties: [Object], children: [Array]},
{type: 'text', value: ' { '},
// …
{type: 'element', tagName: 'span', properties: [Object], children: [Array]},
{type: 'text', value: ' }'}
]
}
starryNight.flagToScope(flag)
Get the grammar scope (such as source.gfm
) associated with a grammar name
(such as markdown
or pandoc
) or grammar extension (such as .md
or .rmd
).
Note that grammars can use the same extensions, in which case GitHub chooses the
first.
Notably, .md
is registered by a lisp-like language instead of markdown.
🤷♂️
flag
(string
)
— grammar name (such as 'markdown'
or 'pandoc'
) or grammar extension
(such as '.md'
or '.rmd'
)Grammar scope, such as 'source.gfm'
(string?
)
import {createStarryNight, common} from '@wooorm/starry-night'
const starryNight = await createStarryNight(common)
console.log(starryNight.flagToScope('pandoc')) // `'source.gfm'`
console.log(starryNight.flagToScope('workbook')) // `'source.gfm'`
console.log(starryNight.flagToScope('.workbook')) // `'source.gfm'`
console.log(starryNight.flagToScope('whatever')) // `undefined`
starryNight.scopes()
List all registered scopes.
List of grammar scopes, such as 'source.gfm'
(Array<string>
).
import {createStarryNight, common} from '@wooorm/starry-night'
const starryNight = await createStarryNight(common)
console.log(starryNight.scopes())
Yields:
[
'source.c',
'source.c++',
// …
'text.xml',
'text.xml.svg'
]
starryNight.register(grammars)
Add more grammars.
grammars
(Array<Grammar>
)
— grammars to supportA promise resolving to nothing (Promise<undefined>
).
import {toHtml} from 'hast-util-to-html'
import {createStarryNight} from '@wooorm/starry-night'
import sourceGfm from '@wooorm/starry-night/lang/source.gfm.js'
import sourceCss from '@wooorm/starry-night/lang/source.css.js'
const markdown = '```css\nem { color: red }\n```'
const starryNight = await createStarryNight([sourceGfm])
console.log(toHtml(starryNight.highlight(markdown, 'source.gfm')))
await starryNight.register([sourceCss])
console.log(toHtml(starryNight.highlight(markdown, 'source.gfm')))
Yields:
<span class="pl-c1">```css</span>
em { color: red }
<span class="pl-c1">```</span>
<span class="pl-c1">```css</span>
<span class="pl-ent">em</span> { <span class="pl-c1">color</span>: <span class="pl-c1">red</span> }
<span class="pl-c1">```</span>
hast
trees as returned by starry-night
can be serialized with
hast-util-to-html
:
import {toHtml} from 'hast-util-to-html'
import {createStarryNight, common} from '@wooorm/starry-night'
const starryNight = await createStarryNight(common)
const tree = starryNight.highlight('"use strict";', 'source.js')
console.log(toHtml(tree))
Yields:
<span class="pl-s"><span class="pl-pds">"</span>use strict<span class="pl-pds">"</span></span>;
starry-night
on the clientYou don’t have to do preprocess things on a server. Particularly, when you are not using Node.js or so. Or, when you have a lot of often changing content (likely markdown), such as on a page of comments.
In those cases, you can run starry-night
in the browser.
Here is an example.
It also uses hast-util-to-dom
, which is a light way to
turn the AST into DOM nodes.
Say we have this example.js
on our browser (no bundling needed!):
import {createStarryNight, common} from 'https://esm.sh/@wooorm/starry-night@1?bundle'
import {toDom} from 'https://esm.sh/hast-util-to-dom@3?bundle'
const starryNight = await createStarryNight(common)
const prefix = 'language-'
const nodes = Array.from(document.body.querySelectorAll('code'))
for (const node of nodes) {
const className = Array.from(node.classList).find((d) => d.startsWith(prefix))
if (!className) continue
const scope = starryNight.flagToScope(className.slice(prefix.length))
if (!scope) continue
const tree = starryNight.highlight(node.textContent, scope)
node.replaceChildren(toDom(tree, {fragment: true}))
}
…and then, if we would have an index.html
for our document:
<!doctype html>
<meta charset=utf8>
<title>Hello</title>
<link rel=stylesheet href=https://esm.sh/@wooorm/starry-night@1/style/both.css>
<body>
<h1>Hello</h1>
<p>…world!</p>
<pre><code class="language-js">console.log('it works!')
</code></pre>
<script type=module src=./example.js></script>
</body>
Opening that page in a browser, we’d see the <code>
being swapped with:
<code class="language-js"><span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">'</span>it works!<span class="pl-pds">'</span></span>)
</code>
hast trees as returned by starry-night
can be turned into React (or Preact,
Vue, &c) with hast-to-hyperscript
:
import {createStarryNight, common} from '@wooorm/starry-night'
import {toH} from 'hast-to-hyperscript'
import React from 'react'
const starryNight = await createStarryNight(common)
const tree = starryNight.highlight('"use strict";', 'source.js')
const reactNode = toH(React.createElement, tree)
console.log(reactNode)
Yields:
{
'$$typeof': Symbol(react.element),
type: 'div',
key: 'h-1',
ref: null,
props: {children: [[Object], ';']},
_owner: null,
_store: {}
}
GitHub itself does not add line numbers to the code they highlight. You can do that, by transforming the AST. Here’s an example of a utility that wraps each line into a span with a class and a data attribute with its line number. That way, you can style the lines as you please. Or you can generate different elements for each line, of course.
Say we have our utility as hast-util-starry-night-gutter.js
:
/**
* @typedef {import('hast').Root} Root
* @typedef {import('hast').RootContent} RootContent
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('hast').Element} Element
*/
/**
* @template {Root} Tree
* @param {Tree} tree
* @returns {Tree}
*/
export function starryNightGutter(tree) {
/** @type {Array<RootContent>} */
const replacement = []
const search = /\r?\n|\r/g
let index = -1
let start = 0
let startTextRemainder = ''
let lineNumber = 0
while (++index < tree.children.length) {
const child = tree.children[index]
if (child.type === 'text') {
let textStart = 0
let match = search.exec(child.value)
while (match) {
// Nodes in this line.
const line = /** @type {Array<ElementContent>} */ (
tree.children.slice(start, index)
)
// Prepend text from a partial matched earlier text.
if (startTextRemainder) {
line.unshift({type: 'text', value: startTextRemainder})
startTextRemainder = ''
}
// Append text from this text.
if (match.index > textStart) {
line.push({
type: 'text',
value: child.value.slice(textStart, match.index)
})
}
// Add a line, and the eol.
lineNumber += 1
replacement.push(createLine(line, lineNumber), {
type: 'text',
value: match[0]
})
start = index + 1
textStart = match.index + match[0].length
match = search.exec(child.value)
}
// If we matched, make sure to not drop the text after the last line ending.
if (start === index + 1) {
startTextRemainder = child.value.slice(textStart)
}
}
}
const line = /** @type {Array<ElementContent>} */ (tree.children.slice(start))
// Prepend text from a partial matched earlier text.
if (startTextRemainder) {
line.unshift({type: 'text', value: startTextRemainder})
startTextRemainder = ''
}
if (line.length > 0) {
lineNumber += 1
replacement.push(createLine(line, lineNumber))
}
// Replace children with new array.
tree.children = replacement
return tree
}
/**
* @param {Array<ElementContent>} children
* @param {number} line
* @returns {Element}
*/
function createLine(children, line) {
return {
type: 'element',
tagName: 'span',
properties: {className: 'line', dataLineNumber: line},
children
}
}
…and a module example.js
:
import {toHtml} from 'hast-util-to-html'
import {createStarryNight, common} from '@wooorm/starry-night'
import {starryNightGutter} from './hast-util-starry-night-gutter.js'
const starryNight = await createStarryNight(common)
const tree = starryNight.highlight(
'# Some heading\n\n```js\nalert(1)\n```\n***',
'source.gfm'
)
starryNightGutter(tree)
console.log(toHtml(tree))
Now running node example.js
yields:
<span class="line" data-line-number="1"><span class="pl-mh"># Some heading</span></span>
<span class="line" data-line-number="2"></span>
<span class="line" data-line-number="3"><span class="pl-c1">```js</span></span>
<span class="line" data-line-number="4"><span class="pl-en">alert</span>(<span class="pl-c1">1</span>)</span>
<span class="line" data-line-number="5"><span class="pl-c1">```</span></span>
<span class="line" data-line-number="6"><span class="pl-c">***</span></span>
This example shows how to combine starry-night
with unified
:
using remark
to parse the markdown and transforming it to HTML with
rehype
.
If we have a markdown file example.md
:
# Hello
…world!
```js
console.log('it works!')
```
…and a plugin rehype-starry-night.js
:
/**
* @typedef {import('hast').Root} Root
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('@wooorm/starry-night').Grammar} Grammar
*
* @typedef Options
* Configuration (optional)
* @property {Array<Grammar>} [grammars]
* Grammars to support (defaults: `common`).
*/
import {createStarryNight, common} from '@wooorm/starry-night'
import {visit} from 'unist-util-visit'
import {toString} from 'hast-util-to-string'
/**
* Plugin to highlight code with `starry-night`.
*
* @type {import('unified').Plugin<[Options?], Root>}
*/
export default function rehypeStarryNight(options = {}) {
const grammars = options.grammars || common
const starryNightPromise = createStarryNight(grammars)
const prefix = 'language-'
return async function (tree) {
const starryNight = await starryNightPromise
visit(tree, 'element', function (node, index, parent) {
if (!parent || index === null || node.tagName !== 'pre') {
return
}
const head = node.children[0]
if (
!head ||
head.type !== 'element' ||
head.tagName !== 'code' ||
!head.properties
) {
return
}
const classes = head.properties.className
if (!Array.isArray(classes)) return
const language = classes.find(
(d) => typeof d === 'string' && d.startsWith(prefix)
)
if (typeof language !== 'string') return
const scope = starryNight.flagToScope(language.slice(prefix.length))
// Maybe warn?
if (!scope) return
const fragment = starryNight.highlight(toString(head), scope)
const children = /** @type {Array<ElementContent>} */ (fragment.children)
parent.children.splice(index, 1, {
type: 'element',
tagName: 'div',
properties: {
className: [
'highlight',
'highlight-' + scope.replace(/^source\./, '').replace(/\./g, '-')
]
},
children: [{type: 'element', tagName: 'pre', properties: {}, children}]
})
})
}
}
…and finally a module example.js
:
import fs from 'node:fs/promises'
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import rehypeStarryNight from './rehype-starry-night.js'
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeStarryNight)
.use(rehypeStringify)
.process(await fs.readFile('example.md'))
console.log(String(file))
Now running node example.js
yields:
<h1>Hello</h1>
<p>…world!</p>
<div class="highlight highlight-js"><pre><span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">'</span>it works!<span class="pl-pds">'</span></span>)
</pre></div>
markdown-it
This example shows how to combine starry-night
with markdown-it
.
If we have a markdown file example.md
:
# Hello
…world!
```js
console.log('it works!')
```
…and a module example.js
:
import fs from 'node:fs/promises'
import {createStarryNight, common} from '@wooorm/starry-night'
import {toHtml} from 'hast-util-to-html'
import markdownIt from 'markdown-it'
const file = await fs.readFile('example.md')
const starryNight = await createStarryNight(common)
const markdownItInstance = markdownIt({
highlight(value, lang) {
const scope = starryNight.flagToScope(lang)
return toHtml({
type: 'element',
tagName: 'pre',
properties: {
className: scope
? [
'highlight',
'highlight-' + scope.replace(/^source\./, '').replace(/\./g, '-')
]
: undefined
},
children: scope
? starryNight.highlight(value, scope).children
: [{type: 'text', value}]
})
}
})
const html = markdownItInstance.render(String(file))
console.log(html)
Now running node example.js
yields:
<h1>Hello</h1>
<p>…world!</p>
<pre class="highlight highlight-js"><span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">'</span>it works!<span class="pl-pds">'</span></span>)
</pre>
The generated hast
starts with a root
node, that represents the
fragment.
It contains up to three levels of <span>
element
s, each with a single class.
All these levels can contain text nodes with the actual code.
Interestingly, TextMate grammars work per line, so all line endings are in the
root directly, meaning that creating a gutter to display line numbers can be
generated rather naïvely by only looking through the root node.
starry-night
does not inject CSS for the syntax highlighted code (because
well, starry-night
doesn’t have to be turned into HTML and might not run in a
browser!).
If you are in a browser, you can use the packaged themes, or get creative with
CSS!
💅
All themes accept CSS variables (custom properties).
With the theme core.css
, you have to define your own properties.
All other themes define the colors on :root
.
Themes either have a dark
or light
suffix, or none, in which case they
automatically switch colors based on a @media (prefers-color-scheme: dark)
.
All themes are tiny (under 1 kB).
The shipped themes are as follows:
name | Includes light scheme | Includes dark scheme |
---|---|---|
core.css | ||
light.css | ✅ | |
dark.css | ✅ | |
both.css | ✅ | ✅ |
colorblind-light.css | ✅ | |
colorblind-dark.css | ✅ | |
colorblind.css | ✅ | ✅ |
dimmed-dark.css | ✅ | |
dimmed.css | ✅ | ✅ |
high-contrast-light.css | ✅ | |
high-contrast-dark.css | ✅ | |
high-contrast.css | ✅ | ✅ |
tritanopia-light.css | ✅ | |
tritanopia-dark.css | ✅ | |
tritanopia.css | ✅ | ✅ |
Checked grammars are included in common
.
Everything is available through all
.
You can add more grammars as you please.
Each grammar has several associated names and extensions.
See source files for which are known and use flagToScope
to turn them into
scopes.
All licenses are permissive and made available in notice
.
Changes should go to upstream repos and languages.yml
in
github/linguist
.
source.c
— upstreamsource.c++
— upstreamsource.cs
(mit) — upstreamsource.css
(mit) — upstreamsource.css.less
(mit) — upstreamsource.css.scss
(mit) — upstreamsource.diff
source.gfm
(mit) — upstreamsource.go
(bsd-3-clause) — upstreamsource.graphql
(mit) — upstreamsource.ini
source.java
— upstreamsource.js
(mit) — upstreamsource.json
(isc) — upstreamsource.kotlin
(apache-2.0) — upstreamsource.lua
source.makefile
— upstreamsource.objc
source.perl
— upstreamsource.python
(mit) — upstreamsource.r
source.ruby
(mit) — upstreamsource.rust
(mit) — upstreamsource.shell
(mit) — upstreamsource.sql
source.swift
— upstreamsource.ts
(mit) — upstreamsource.vbnet
(apache-2.0) — upstreamsource.yaml
(mit) — upstreamtext.html.basic
(mit) — upstreamtext.html.php
text.xml
text.xml.svg
(isc) — upstreamconfig.xcompose
(mit)file.lasso
(public domain)go.mod
— upstreamgo.sum
— upstreamobjdump.x86asm
(mit)source.2da
(isc) — upstreamsource.4dm
(mit)source.abap
— upstreamsource.abapcds
(unlicense) — upstreamsource.abl
(mit) — upstreamsource.abnf
(isc) — upstreamsource.actionscript.3
(mit) — upstreamsource.ada
source.afm
(isc) — upstreamsource.agc
(isc)source.agda
(mit) — upstreamsource.ahk
(unlicense) — upstreamsource.aidl
(apache-2.0) — upstreamsource.al
(mit) — upstreamsource.alloy
(apache-2.0) — upstreamsource.ampl
(mit)source.angelscript
(unlicense) — upstreamsource.antlr
source.apache-config
source.apl
(isc) — upstreamsource.applescript
source.arr
(mit) — upstreamsource.asl
(mit) — upstreamsource.asn
(mit) — upstreamsource.aspectj
(mit)source.assembly
(bsd-3-clause) — upstreamsource.astro
(mit) — upstreamsource.ats
(mit)source.autoit
(mit)source.avro
(mit) — upstreamsource.awk
(mit)source.ballerina
(apache-2.0) — upstreamsource.basic
(apache-2.0) — upstreamsource.batchfile
(mit) — upstreamsource.bdf
(isc) — upstreamsource.befunge
(mit)source.berry
(mit) — upstreamsource.bf
(mit) — upstreamsource.bicep
(mit) — upstreamsource.blitzmax
source.boo
(mit) — upstreamsource.boogie
(mit) — upstreamsource.bp
(mit) — upstreamsource.brs
(mit) — upstreamsource.bsl
(mit) — upstreamsource.bsv
(mit)source.c.ec
(unlicense) — upstreamsource.c.nwscript
(isc) — upstreamsource.cabal
(mit) — upstreamsource.cadence
(apache-2.0) — upstreamsource.cairo
(mit) — upstreamsource.capnp
source.cds
(apache-2.0) — upstreamsource.ceylon
(apache-2.0)source.cfscript
(mit)source.chapel
(apache-2.0) — upstreamsource.cil
(apache-2.0) — upstreamsource.circom
(mit) — upstreamsource.cirru
(mit) — upstreamsource.clar
(mit) — upstreamsource.clarion
(mit) — upstreamsource.clean
(mit)source.click
(mit)source.clips
(mit)source.clojure
(mit) — upstreamsource.cmake
source.cobol
(mit) — upstreamsource.coffee
(mit) — upstreamsource.cool
(mit)source.coq
(mit)source.crystal
(mit)source.csound
(mit) — upstreamsource.csound-document
(mit) — upstreamsource.csound-score
(mit) — upstreamsource.css.mss
(mit)source.css.postcss.sugarss
(mit)source.csswg
— upstreamsource.cuda-c++
(bsd-3-clause) — upstreamsource.cue
(mit) — upstreamsource.cuesheet
(mit) — upstreamsource.curlrc
(isc) — upstreamsource.curry
(mit) — upstreamsource.cwl
(mit)source.cypher
(apache-2.0) — upstreamsource.cython
source.d
— upstreamsource.dart
(bsd-3-clause) — upstreamsource.data-weave
(mit) — upstreamsource.deb-control
(mit) — upstreamsource.denizenscript
(mit) — upstreamsource.desktop
source.dircolors
(mit)source.dm
(mit)source.dockerfile
(mit) — upstreamsource.dot
source.dotenv
(isc) — upstreamsource.dylan
source.earthfile
(mpl-2.0) — upstreamsource.ebnf
(isc) — upstreamsource.ecl
(apache-2.0) — upstreamsource.editorconfig
(mit) — upstreamsource.eiffel
source.elixir
(apache-2.0) — upstreamsource.elm
(mit) — upstreamsource.elvish
(bsd-2-clause) — upstreamsource.elvish-transcript
(bsd-2-clause) — upstreamsource.emacs.lisp
(isc) — upstreamsource.erlang
— upstreamsource.euphoria
(mit) — upstreamsource.factor
(bsd-2-clause)source.fan
(mit)source.fancy
(bsd-3-clause) — upstreamsource.faust
(mit)source.figfont
(isc) — upstreamsource.firestore
(mit)source.fish
(mit)source.fnl
(mit) — upstreamsource.fontdir
(isc) — upstreamsource.forth
source.fortran
source.fortran.modern
source.fsharp
(mit) — upstreamsource.fstar
(apache-2.0) — upstreamsource.ftl
(mit) — upstreamsource.futhark
(isc) — upstreamsource.gap
— upstreamsource.gcode
(mit) — upstreamsource.gdb
(zlib) — upstreamsource.gdresource
(mit) — upstreamsource.gdscript
(mit) — upstreamsource.gedcom
(apache-2.0) — upstreamsource.gemfile-lock
(mit) — upstreamsource.gemini
(mit) — upstreamsource.generic-db
(isc) — upstreamsource.genero
(mit) — upstreamsource.genero-forms
(mit) — upstreamsource.gerber
(isc) — upstreamsource.gf
(mit) — upstreamsource.git-revlist
(isc) — upstreamsource.gitattributes
(isc) — upstreamsource.gitconfig
(isc) — upstreamsource.gitignore
(isc) — upstreamsource.gleam
(apache-2.0) — upstreamsource.glsl
(unlicense) — upstreamsource.gn
(bsd-3-clause) — upstreamsource.gnuplot
(mit)source.golo
(mit) — upstreamsource.gosu.2
(apache-2.0) — upstreamsource.grace
(mit)source.groovy
source.groovy.gradle
(apache-2.0)source.gsc
(unlicense) — upstreamsource.hack
(mit) — upstreamsource.haproxy-config
(mit)source.harbour
(mit)source.haskell
(mit) — upstreamsource.hc
(unlicense)source.hlsl
(mit)source.hocon
(mit) — upstreamsource.hoon
(mit) — upstreamsource.hql
(mit)source.httpspec
(mit) — upstreamsource.hx
(mit) — upstreamsource.hxml
(mit) — upstreamsource.hy
(mit) — upstreamsource.idl
(bsd-3-clause) — upstreamsource.idris
(mit) — upstreamsource.igor
(bsd-3-clause) — upstreamsource.imba
(mit) — upstreamsource.inform7
(mit) — upstreamsource.ini.npmrc
(isc) — upstreamsource.ink
(mit) — upstreamsource.inno
(mit) — upstreamsource.inputrc
(isc) — upstreamsource.io
source.ioke
(mit)source.isabelle.root
(bsd-2-clause) — upstreamsource.isabelle.theory
(bsd-2-clause) — upstreamsource.j
(mit) — upstreamsource.janet
(mit) — upstreamsource.jasmin
(mit)source.java-properties
— upstreamsource.jcl
(mit) — upstreamsource.jest.snap
(mit) — upstreamsource.jflex
(bsd-2-clause)source.jison
(mit)source.jisonlex
(mit)source.jolie
(mit)source.jq
(mit) — upstreamsource.js.objj
source.jsoniq
(apache-2.0) — upstreamsource.jsonnet
(apache-2.0) — upstreamsource.julia
(mit) — upstreamsource.just
(mit) — upstreamsource.kakscript
(unlicense) — upstreamsource.kerboscript
(mit) — upstreamsource.keyvalues
(isc) — upstreamsource.kickstart
(mit) — upstreamsource.kusto
(apache-2.0) — upstreamsource.lark
(isc) — upstreamsource.lean
(apache-2.0) — upstreamsource.lex
(isc) — upstreamsource.ligo
(mit) — upstreamsource.lilypond
(mit) — upstreamsource.lisp
source.litcoffee
(mit) — upstreamsource.livescript
(mit) — upstreamsource.llvm
(mit) — upstreamsource.logos
(mit) — upstreamsource.logtalk
source.loomscript
(mit)source.lsl
source.ltspice.symbol
(isc) — upstreamsource.m2
(mit) — upstreamsource.m4
(isc) — upstreamsource.m68k
(mit)source.mask
(mit)source.mathematica
(apache-2.0) — upstreamsource.matlab
(bsd-2-clause) — upstreamsource.maxscript
(isc)source.mc
(mit)source.mcfunction
(mit) — upstreamsource.mercury
(mit)source.mermaid
(isc) — upstreamsource.meson
(apache-2.0) — upstreamsource.miniyaml
(mit) — upstreamsource.mint
(mit) — upstreamsource.ml
— upstreamsource.mligo
(mit) — upstreamsource.mlir
(apache-2.0) — upstreamsource.mo
(apache-2.0) — upstreamsource.modelica
(mit) — upstreamsource.modula-3
(bsd-3-clause) — upstreamsource.modula2
(mit) — upstreamsource.monkey
(mit)source.moonscript
(mit)source.move
(mit) — upstreamsource.mql5
(mit)source.msl
(mit) — upstreamsource.mupad
(mit) — upstreamsource.nanorc
(isc) — upstreamsource.nasl
(mit) — upstreamsource.ncl
(mit)source.ne
(unlicense) — upstreamsource.nemerle
source.neon
(isc) — upstreamsource.nesc
(mit)source.netlinx
(mit)source.netlinx.erb
(mit)source.nextflow
(mit)source.nginx
(mit) — upstreamsource.nim
(mit) — upstreamsource.ninja
(mit)source.nit
(wtfpl)source.nix
(mit) — upstreamsource.nsis
(apache-2.0)source.nu
(apache-2.0)source.nut
(mit)source.objc++
source.objectscript
(mit)source.ocaml
source.odin
(mit) — upstreamsource.odin-ehr
(isc) — upstreamsource.ooc
(bsd-2-clause)source.opa
(mit) — upstreamsource.opal
(mit) — upstreamsource.opentype
(isc) — upstreamsource.opts
(isc) — upstreamsource.ox
(mit)source.oz
(mit)source.p4
(mit)source.pan
(mit)source.papyrus.skyrim
(mit)source.parrot.pir
source.pascal
source.pawn
(mit)source.pcb.board
(isc) — upstreamsource.pcb.schematic
(isc) — upstreamsource.pcb.sexp
(isc) — upstreamsource.pddl
(mit) — upstreamsource.pegjs
(isc) — upstreamsource.pep8
(wtfpl)source.php.zephir
— upstreamsource.pic
(isc) — upstreamsource.pig_latin
(mit)source.pike
(unlicense)source.plist
(mit) — upstreamsource.po
source.pogoscript
(mit)source.polar
(apache-2.0) — upstreamsource.pony
(bsd-2-clause) — upstreamsource.portugol
(mit) — upstreamsource.postcss
(mit)source.postscript
(isc) — upstreamsource.pov-ray sdl
(mit)source.powershell
(mit) — upstreamsource.prisma
(apache-2.0) — upstreamsource.processing
source.procfile
(bsd-3-clause) — upstreamsource.prolog
(mpl-2.0)source.prolog.eclipse
(mpl-2.0)source.promela
(mit) — upstreamsource.proto
(mit) — upstreamsource.puppet
(mit) — upstreamsource.purescript
(mit) — upstreamsource.python.kivy
(mit) — upstreamsource.q
(mit) — upstreamsource.qasm
(mit)source.ql
(mit) — upstreamsource.qmake
source.qml
(mit)source.qsharp
(mit) — upstreamsource.quake
(bsd-3-clause)source.racket
(mit)source.raku
— upstreamsource.rascal
(bsd-2-clause) — upstreamsource.reason
(mit) — upstreamsource.rebol
(mit) — upstreamsource.record-jar
(isc) — upstreamsource.red
(mit) — upstreamsource.redirects
(isc) — upstreamsource.reg
(mit)source.regexp
(isc) — upstreamsource.rego
(apache-2.0) — upstreamsource.religo
(mit) — upstreamsource.renpy
(mit) — upstreamsource.rescript
(mit) — upstreamsource.rexx
(mit) — upstreamsource.ring
(mit)source.rpgle
(mit) — upstreamsource.rpm-spec
(mit)source.sas
(mit) — upstreamsource.sass
(mit) — upstreamsource.scad
(mit) — upstreamsource.scala
— upstreamsource.scaml
(apache-2.0) — upstreamsource.scenic
(mit) — upstreamsource.scheme
source.scilab
source.sed
(isc) — upstreamsource.sepolicy
(apache-2.0) — upstreamsource.sfv
(isc) — upstreamsource.shaderlab
(mit)source.shellcheckrc
(isc) — upstreamsource.shen
(bsd-3-clause)source.sieve
(isc) — upstreamsource.singularity
(mit) — upstreamsource.slice
(bsd-3-clause) — upstreamsource.smali
(mit) — upstreamsource.smalltalk
(mit)source.smithy
(apache-2.0) — upstreamsource.smpl
(isc) — upstreamsource.smt
(unlicense)source.solidity
(mit) — upstreamsource.solution
(isc) — upstreamsource.sourcepawn
(mit) — upstreamsource.sparql
(mit) — upstreamsource.spin
(zlib) — upstreamsource.sqf
(apache-2.0) — upstreamsource.ssh-config
(isc) — upstreamsource.stan
(mit) — upstreamsource.star
(isc) — upstreamsource.stata
(mit) — upstreamsource.stl
(isc) — upstreamsource.string-template
(isc) — upstreamsource.stylus
(mit)source.supercollider
(mit) — upstreamsource.svelte
(mit) — upstreamsource.sway
(apache-2.0) — upstreamsource.systemverilog
(apache-2.0) — upstreamsource.talon
(mit) — upstreamsource.tcl
source.tea
(apache-2.0)source.terra
(bsd-3-clause)source.terraform
(mit) — upstreamsource.textproto
(mit) — upstreamsource.thrift
source.tl
(mit)source.tla
(mit)source.tm-properties
— upstreamsource.toc
(unlicense) — upstreamsource.toml
— upstreamsource.tsql
(mit) — upstreamsource.tsx
(mit) — upstreamsource.turing
(isc) — upstreamsource.turtle
(mit) — upstreamsource.txl
(apache-2.0) — upstreamsource.ur
(mit)source.v
(mit) — upstreamsource.vala
(mit) — upstreamsource.varnish.vcl
(mit) — upstreamsource.velocity
(mit) — upstreamsource.verilog
source.vhdl
source.vim-snippet
(mit) — upstreamsource.viml
(mit) — upstreamsource.vyper
(mit) — upstreamsource.wavefront.mtl
(isc) — upstreamsource.wavefront.obj
(isc) — upstreamsource.wdl
(bsd-3-clause) — upstreamsource.webassembly
(isc) — upstreamsource.webidl
(mit) — upstreamsource.wgetrc
(isc) — upstreamsource.whiley
(apache-2.0) — upstreamsource.win32-messages
(isc) — upstreamsource.witcherscript
(mit) — upstreamsource.wollok
(mit)source.wren
(mit) — upstreamsource.wsd
(mit) — upstreamsource.x10
(apache-2.0)source.x86
(mit) — upstreamsource.xc
source.xojo
(apache-2.0) — upstreamsource.xq
(apache-2.0) — upstreamsource.xtend
(mit)source.yacc
(isc) — upstreamsource.yaml.salt
(mit) — upstreamsource.yang
(mit)source.yara
(mit) — upstreamsource.yasnippet
(isc) — upstreamsource.yul
(mit) — upstreamsource.zap
source.zeek
(bsd-3-clause) — upstreamsource.zenscript
(mit) — upstreamsource.zig
(mit) — upstreamsource.zil
text.adblock
(mit) — upstreamtext.bibtex
— upstreamtext.browserslist
(mit) — upstreamtext.checksums
(isc) — upstreamtext.codeowners
(isc) — upstreamtext.conllu
(apache-2.0)text.dfy.dafny
(mit) — upstreamtext.eml.basic
(mit) — upstreamtext.gherkin.feature
(mit) — upstreamtext.haml
(mit)text.html.asciidoc
(mit) — upstreamtext.html.asp
text.html.cfm
(mit)text.html.creole
(mit) — upstreamtext.html.cshtml
(mit) — upstreamtext.html.django
text.html.ecmarkup
(isc) — upstreamtext.html.ecr
(mit)text.html.elixir
(apache-2.0) — upstreamtext.html.erb
(mit) — upstreamtext.html.ftl
(mit)text.html.handlebars
(mit)text.html.js
(mit)text.html.jsp
— upstreamtext.html.liquid
(mit) — upstreamtext.html.mako
(mit)text.html.markdown.source.gfm.apib
(mit) — upstreamtext.html.mediawiki
text.html.nunjucks
(mit)text.html.php.blade
(mit)text.html.riot
(mit)text.html.slash
(mit)text.html.smarty
text.html.soy
(mit)text.html.statamic
(mit) — upstreamtext.html.twig
(bsd-3-clause) — upstreamtext.html.vue
(mit) — upstreamtext.jade
(mit)text.marko
(mit) — upstreamtext.muse
(isc) — upstreamtext.python.console
(mit) — upstreamtext.python.traceback
(mit) — upstreamtext.rdoc
(mit)text.restructuredtext
(mit) — upstreamtext.robot
(apache-2.0) — upstreamtext.robots-txt
(isc) — upstreamtext.roff
(isc) — upstreamtext.rtf
(mit) — upstreamtext.runoff
(isc) — upstreamtext.sfd
(isc) — upstreamtext.shell-session
(mit) — upstreamtext.slim
(mit)text.srt
(isc) — upstreamtext.tex.latex
— upstreamtext.tex.latex.haskell
(mit) — upstreamtext.texinfo
(isc) — upstreamtext.vim-help
(mit) — upstreamtext.vtt
(isc) — upstreamtext.xml.ant
(mit)text.xml.plist
(mit) — upstreamtext.xml.pom
text.xml.xsl
text.zone_file
(mit) — upstreamThis package is fully typed with TypeScript.
It exports additional Grammar
, Root
, Options
, and GetOnigurumaUrl
types that model their respective interfaces.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+, 16.0+, and 18.0+. It also works in Deno and modern browsers.
You can pass your own TextMate grammars, provided that they work with
vscode-textmate
, and that they have the added fields
scopeName
, names
, and extensions
(see types for the definitions and the
grammars in lang/
for examples).
This package is safe.
Yes please! See How to Contribute to Open Source.
The grammars included in this package are covered by their repositories’
respective licenses, which are permissive (apache-2.0
, mit
, etc), and made
available in notice
.
All other files MIT © Titus Wormer
FAQs
Syntax highlighting, like GitHub
The npm package @wooorm/starry-night receives a total of 23,781 weekly downloads. As such, @wooorm/starry-night popularity was classified as popular.
We found that @wooorm/starry-night demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.